package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	UserName     string `gorm:"type:varchar(30);commit:用户名"`
	Password     string `gorm:"type:varchar(32);commit:密码"`
	Status       int    `gorm:"type:int;commit:1:正常,2:异常"`
	MemberStatus int    `gorm:"type:int;commit:1:在期,2:到期"`
}

func (u *User) Register(DB *gorm.DB) error {
	var err error
	err = DB.Create(&u).Error
	return err
}

func (u *User) IsUserName(DB *gorm.DB, username string) error {
	var err error
	err = DB.Where("user_name = ?", username).Find(&u).Error
	return err
}
